package util.src.com;

import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: Gosin
 * @Date: 2020/11/6 20:47
 */
public class CreatThreadPool {
    public Queue<String> queue;
    public String path;
    public int threadNum;
    public ReturnDoneNum obj;

    public CreatThreadPool(Queue<String> queue, String path, int threadNum, ReturnDoneNum obj) {
        this.queue = queue;
        this.path = path;
        this.threadNum = threadNum;
        this.obj = obj;
    }

    public void management() {
        ExecutorService pool = Executors.newCachedThreadPool();
        for (int i = 0; i < threadNum; i++) {
            MyCallThread mt = new MyCallThread(queue, path, obj);
            pool.submit(mt);
        }
        //关闭线程池
        pool.shutdown();
    }
}

